package com.mall.manager.service.imp;

import com.alibaba.dubbo.config.annotation.Service;
import com.mall.manager.dao.TbItemDescMapper;
import com.mall.manager.pojo.TbItemDesc;
import com.mall.manager.service.ItemDescService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * @author Administrator
 */

@Service
@Transactional
@Component
public class ItemDescServiceImp implements ItemDescService {

    @Autowired
    private TbItemDescMapper itemDescMapper;

    /**
     * 根据商品商品id查询商品描述信息
     * @param id
     * @return
     */
    @Override
    public TbItemDesc getById(long id) {
        try {
            itemDescMapper.selectByPrimaryKey(id);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public void update(Long id, String desc) {
        TbItemDesc itemDesc = itemDescMapper.selectByPrimaryKey(id);
        itemDesc.setUpdated(new Date());
        itemDesc.setItemDesc(desc);
        itemDescMapper.updateByPrimaryKey(itemDesc);
    }
}
